<template>
   <form>
       <slot></slot>
   </form>
</template>
<script>
export default {
    name:'PForm',
    provide(){
        return{
            form: this
        }
    },
    props:{
        model:{
            type:Object
        },
        rules:{
            type: Object
        }
    },
    methods:{
        validate(cb){
           const tasks = this.$children
            .filter(child => child.prop)
            .map(child => child.validate())
           return Promise.all(tasks).then(()=>{
               cb(true)
           }).catch(()=>{
               cb(false)
           })
        }
    }
}
</script>
<style>
</style>